package engine.display.Story 
{
	import engine.GameData;
	import engine.data.ModelLocator;
	import engine.display.InterceptMsgLogic;
	import engine.display.Story.ActionControl.TalkActionPlay;
	import engine.display.Story.ActionItem.EndBlackTalkInfoUI;
	import engine.display.Story.ActionItem.TalkInformationUI;
	import engine.display.Story.StoryMoveEvent.StoryEvent;
	import engine.event.SceneEvent;
	import engine.flag.GameDefine;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.scene.SceneChangeManager;
	import engine.scene.SceneManager;
	import engine.scene.SceneRoleLoadLogic;
	import engine.scene.SceneView;
	import engine.scene.player.NpcModel;
	import engine.ui.MainUIManager;
	import engine.ui.lite.BaseUI;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.button.NxButton;
	import newx.com.loader.SwfLoader;

	/**
	 * ...
	 * NPC聊天动画
	 * @author WangHaiBo  www.woniu.com
	 */
	public class StoryMoveUI extends BaseUI
	{
		public static var IsStory : Boolean = false;
		
		private var storyFunBack:Sprite;

		//前景层的遮罩
		private var frameMask		:Sprite;
		//背景层的遮罩
		private var sceneMask		:Sprite
		//对话显示层的遮罩
		private var talkMask		:Sprite
		//人物层的遮罩
		private var playMask		:Sprite
		//背景总合
		private var sceneAll		:MovieClip;
		//最底层
		private var bSceneBack		:MovieClip
		//背景层
		private var sceneBlack		:MovieClip;
		//前场景
		private var frameBlack		:MovieClip;
		//人物层
		private var playSpace		:Sprite;
		//动画框
		private var maskSpce		:MovieClip
		//对话显示层
		private var talkSpace		:Sprite;
		//聊天内容数组
		private var talkInfoObj	:Object
		//动作数
		private var talkCount:int
		//显示对象存储器
		private var talkNpcObj		:Object;
		private var startTalkObj	:Object;
		private var endTalkObj		:StoryVo;
		//动作数组
		private var talkItemArray:Array;
		//上一个动作类型
		private var beforeType:int	=	-1;
		private var nextType:int	=	-1;
		/***人物模型**/
		private var playSkinList:Array;
		/**
		 * AUTO_GO_BEFORE 这些类型的播放完毕 自动播放下一个
		 * AUTO_GO_NEXT	  这些类型的是下一个播放 就在上一个播放完毕后立即播放
		 */		
		private const AUTO_GO_BEFORE:Array=[2,3,9,10,11], AUTO_GO_NEXT:Array=[9];//(beforeType == 2 || beforeType == 3 ||beforeType == 10)
		private var talkIndex:int	=	0;
		private static var _self	:StoryMoveUI
		private var zeroStr:String	=	"";
		private var _sendStoryID:String;
		private var _model:ModelLocator;
		private var showWidth:int	=	1280;
		private var showHeight:int	=	750
		private var _sceneData:Array;
		private var _sourUrlArray:Array
		//是否在播放动画
		private var _isPlayMove:Boolean	=	false;
		
		//结束剧情用的对话形式
		private var _endBlackInfoUI:EndBlackTalkInfoUI;
		
		private var skipMc			:NxButton	=	new NxButton();		
		
		private var _bitMap			:	Bitmap;
		
		public var _sceneEvent		:CustomMsgEvent;
		public function StoryMoveUI() 
		{
			init();
		}
		
		public static function getInstance():StoryMoveUI
		{
			if (_self == null) 
			{
				_self	=	new StoryMoveUI();
			}
			return _self;
		}
		
		private function init():void
		{
			//上下边框
			var topMc:MovieClip		=	ResManager.newResClass("web_004") as MovieClip;	
			var bottomMc:MovieClip	=	ResManager.newResClass("web_004") as MovieClip;
			
			skipMc.skin				=	"Button_10";
			skipMc.label			=	"";
			skipMc.width			=	54;
			skipMc.height			=	121;
			
			skipMc.y			=	560;
			skipMc.x			=	1240;
			
			skipMc.buttonMode	=	true;
			skipMc.addEventListener(MouseEvent.CLICK,function onSkip(e:MouseEvent):void
			{
				_isPlayMove		=	false;
				skipMc.visible	=	false;
				clickHandle();
			});
				
			_endBlackInfoUI	=	EndBlackTalkInfoUI.getInstance();
			_model			=	ModelLocator.getInstance();
			storyFunBack	=	new Sprite();
			playMask		=	new Sprite();
			talkMask		=	new Sprite();
			sceneMask		=	new Sprite();
			sceneAll		=	new MovieClip();
			sceneBlack		=	new MovieClip();
			frameBlack		=	new MovieClip();
			bSceneBack		=	new MovieClip();
			playSpace		=	new Sprite();
			talkSpace		=	new Sprite();
			frameMask		=	new Sprite();
			maskSpce		=	new MovieClip();

			topMc.x			=	bottomMc.x	=	640;
			topMc.width		=	bottomMc.width	=	showWidth + 100;
			topMc.y 		=	0
			bottomMc.y		=	740;
			
			maskSpce.addChild(topMc);
			maskSpce.addChild(bottomMc);
			//遮罩容器
			storyFunBack.graphics.beginFill(0x000000);
			storyFunBack.graphics.drawRect(0, 0, showWidth * 3, showHeight *3);
			storyFunBack.graphics.endFill();
			
			
			talkMask.graphics.beginFill(0x000000 , .5);
			talkMask.graphics.drawRect(0, 0,showWidth, showHeight);
			talkMask.graphics.endFill();
						
			sceneMask.graphics.beginFill(0x000000 , .5);
			sceneMask.graphics.drawRect(0, 0, showWidth, showHeight);
			sceneMask.graphics.endFill();
			
			playMask.graphics.beginFill(0x000000 , .5);
			playMask.graphics.drawRect(0, 0, showWidth, showHeight);
			playMask.graphics.endFill();
			
			frameMask.graphics.beginFill(0x000000);
			frameMask.graphics.drawRect(0, 0, showWidth, showHeight);
			frameMask.graphics.endFill();
			
			storyFunBack.x	=	-1280
			storyFunBack.y	=	-768
			this.addChild(sceneAll);
			sceneAll.addChild(bSceneBack);
			sceneAll.addChild(sceneBlack);
			this.addChild(playSpace);
			this.addChild(frameBlack);
			this.addChild(maskSpce);
			this.addChild(talkSpace);
			this.addChild(storyFunBack);
			
			
			
			this.addChild(sceneMask);
			this.addChild(frameMask);
			this.addChild(talkMask);
			this.addChild(playMask);
			
			sceneAll.visible	=	false
			sceneAll.mask		=	sceneMask;
			frameBlack.mask		=	frameMask;
			talkSpace.mask		=	talkMask;
			playSpace.mask		=	playMask;
			storyFunBack.alpha	=	0;
			storyFunBack.mouseEnabled	=	false;
			StoryActionManage.getInstance().addEventListener(StoryEvent.TALK_OVER, talkOver)
			//changeLocation();
		}
		
		public function changeSkipBtnState(boolean:Boolean):void
		{
			if(boolean)
			{
				skipMc.visible	=	true;
				this.addChild(skipMc);
			}
			else
			{
				if(!this.contains(skipMc)) return;
				this.removeChild(skipMc);
			}
		}
		/**
		 * 贴边处理
		 */
		public function changeLocation():void
		{
			this.x	=	SceneChangeManager.attackSceneViewX;
			this.y	=	SceneChangeManager.attackSceneViewY;
			_endBlackInfoUI.changeLocation(showWidth, showHeight);
			StoryActionManage.getInstance().changeLocation(showWidth, showHeight);
		}
		/**
		 * 显示聊天动画，
		 * @param	talkID 索引号
		 */
		public function showTalkInfo(talkID:String):void
		{
			TalkInformationUI.getInstance().first	=	true;
			playSkinList = [];
			_sourUrlArray		=	[];
			storyFunBack.alpha	=	0;
			playMask.visible	=	true;
			sceneMask.visible	=	true
			talkMask.visible	=	true;
			frameMask.visible	=	true;
			sceneAll.mask		=	sceneMask;
			talkSpace.mask		=	talkMask;
			playSpace.mask		=	playMask;
			frameBlack.mask		=	frameMask;

			frameBlack.visible	=	true;
			sceneAll.visible	=	true;
			playSpace.visible	=	true;
			maskSpce.visible	=	true;
			talkSpace.visible	=	true;
			_sendStoryID	=	talkID
			clearAll();
			IsStory = true;
			talkIndex		=	0;
			talkNpcObj		=	{ };
			startTalkObj	=	{ };
			endTalkObj		=	new StoryVo();
			talkItemArray	=	[ ];
			var tempStr:String	=	""
			var tempArray:Array	=	[];
			talkInfoObj		=	StaticIni.getIniObj(talkID);
			if (talkInfoObj == null) return; 
			
			//解析剧情主文件
			startTalkObj["type"]		=	talkInfoObj["type"];
			startTalkObj["ConfigID"]	=	talkInfoObj["Storyid"];
			startTalkObj["SceneID"]		=	talkInfoObj["Sceneid"];
			talkCount					=	talkInfoObj["Count"];
			
			var i:int = 0;
			//解析动作文件
			for ( i = 1; i <=  talkCount; i++)
			{
				zeroStr	=	"00".slice(0, 2-String(i).length) + String(i);
				readTaskItem(StaticIni.getIniObj("Act_" +startTalkObj["ConfigID"]+"_"+ zeroStr)["r"]);
			}
			
			//解析结束文件
			endTalkObj	=	talkItemArray.pop();
			
			var configID:int = startTalkObj["SceneID"];
			var start : int = 6;
			var isNewScene : int = StaticIni.getIniObj( "Scene_IsNewSceneLoading" )[ configID ];
//			for( i = start; i <= start + 12; i++ )
//			{
//				_sourUrlArray.push("res/scenes/" + "mscene_" + configID + "_" + i + ".swf");
//				
//			}
//			if( isNewScene == 1 )
//			{
//				_sourUrlArray.push("res/scenes/" + "fscene_" + configID + ".swf");
//			}
		
			_model.addEventListener(SceneEvent.onLoadRoleComplete,loadOver)
			if(_sourUrlArray.length <= 0)
			{
				loadOver();
			}else
			{
				SceneRoleLoadLogic.getInstance().loadRoleRes(_sourUrlArray);
			}
		}
		/**
		 * 全部加载完了 
		 * @param val
		 * 
		 */		
		private function loadOver(e:SceneEvent = null):void
		{
			addSceneBG(startTalkObj["SceneID"]);
	
			for(var i:int = 0;i<playSkinList.length;i+=2)
			{
				var playmc:TalkActionPlay = playSkinList[i] as TalkActionPlay;
				playmc.setSkin(playSkinList[i+1]);
			}
			_model.removeEventListener(SceneEvent.onLoadRoleComplete,loadOver)
			enableChickChange();
			playMovie(talkIndex);
			this.show();
			MainUIManager.getInstance().hideAll();
		}
		/**
		 * 开始播放动画
		 */
		private function playMovie(index:int):void
		{
			_isPlayMove	=	true;
			var nextObj:StoryVo	=	null;
			var infoObj:StoryVo	=	talkItemArray[index] as StoryVo;
			if(index < talkItemArray.length)
			{
				nextObj = talkItemArray[index + 1] as StoryVo
			}
			//this.removeEventListener(MouseEvent.CLICK, clickHandle)
			StoryActionManage.getInstance().showTalk(infoObj, talkSpace);
			beforeType	=	infoObj.type;//AUTO_GO_BEFORE
			if(nextObj)
			{
				nextType	=	nextObj.type;//AUTO_GO_NEXT
			}
			else
			{
				nextType	=	-1;
			}

		}
		public function enableChickChange():void
		{
			this.addEventListener(MouseEvent.CLICK, clickHandle)
		}
		public function disableClickChange():void
		{
			this.removeEventListener(MouseEvent.CLICK, clickHandle)
		}
		private function clickHandle(e:MouseEvent=null):void 
		{
			if(_isPlayMove)return;
			if(e==null) talkIndex = talkItemArray.length;
			talkIndex++;
			if (talkIndex >= talkItemArray.length)
			{
				_isPlayMove	=	true;
				disableClickChange();
				if (endTalkObj.type == 6)
				{
					//传场景
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SCENE_TRANSFER_BEGIN, endTalkObj["ConfigID"]);
					removeAll();
					return;
				}
				else if (endTalkObj.type == 4)
				{
					endTalkObj.TalkInfo	=	"";
					closeStoryMovie(endTalkObj);
					return;
				}
				else if(endTalkObj.type == 5)
				{
					
				}
				closeStoryMovie(endTalkObj);
				return;
			}
			else
			{
				playMovie(talkIndex);
			}
		}
		
		/**
		 * 对话结束
		 * @param	e
		 */
		private function talkOver(e:StoryEvent):void 
		{
			_isPlayMove		=	false;
			//当上一个动作为黑幕和NPC移动 ,swf动画时不需要点击触发
//			trace("StoryMoveUI.talkOver(e)",beforeType,nextType,AUTO_GO_BEFORE.indexOf(beforeType),AUTO_GO_NEXT.indexOf(nextType),_isPlayMove);
			if (AUTO_GO_BEFORE.indexOf(beforeType)!=-1	||	AUTO_GO_NEXT.indexOf(nextType)!=-1) 
			{
//				clickHandle(null);
				dispatchEvent(new MouseEvent(MouseEvent.CLICK));
			}
			else
			{
				
//				this.addEventListener(MouseEvent.CLICK, clickHandle)
			}
		}
		/**
		 * 解析动作内容
		 */
		private function readTaskItem(str:String):void
		{
			var actionItem:StoryVo		=	new StoryVo();
			var tempArray:Array			=	str.split(",");
			var tempPointArray:Array	=	[];
			//动作类型
			actionItem.type			=	tempArray[0];
			if (actionItem.type == 2  || actionItem.type == 9) 
			{
				var configArray:Array		=	(tempArray[2] as String).split("|");
				var imageAlignArray:Array	=	(tempArray[6] as String).split("|");
				var StartPointArray:Array	=	(tempArray[7] as String).split("|");
				var endPointArray:Array		=	(tempArray[8] as String).split("|");
				for (var i:int = 0; i < tempArray[1]; i++) 
				{
					var item:StoryVo		=	new StoryVo();
					//对象数量
					item.count				=	1;
					//动作类型
					item.type				=	2;
					//NPC半身像
					item.ImageID			=	tempArray[3];
					//文本位置
					item.TextAlign			=	tempArray[4];
					//文本编号
					item.TalkInfo			=	StaticIni.getSwfLangStr(tempArray[5]);
					//对象编号
					item.NpcConfigID		=	configArray[i];
					//人物名
					item.Name				=	getNpcName(item.NpcConfigID);	
					//NPC面向
					item.ImageAlign			=	imageAlignArray[i];
					//NPC初始位置
					tempPointArray			=	(StartPointArray[i] as String).split("_")
					item.NpcStartPoint		=	new Point(tempPointArray[0], tempPointArray[1]);
					//NPC结束位置
					tempPointArray			=	(endPointArray[i] as String).split("_");
					
					item.NpcEndPoint		=	new Point(tempPointArray[0], tempPointArray[1]);
					
					addNpc(item.NpcConfigID, item.NpcStartPoint,item.ImageAlign,item);
					actionItem.dataArray.push(item);
				}
			}
			else if(actionItem.type == 10)
			{
				actionItem.count			=	tempArray[1];
				actionItem.swfURL			=	tempArray[2];
			}
			else
			{
				//对象数量
				actionItem.count			=	tempArray[1];
				//对象编号
				actionItem.NpcConfigID		=	tempArray[2];
				//人物名
				actionItem.Name				=	getNpcName(actionItem.NpcConfigID);	
				//NPC半身像
				actionItem.ImageID			=	actionItem.NpcConfigID == "-1"?getRoleModle():tempArray[3];
				//文本位置
				actionItem.TextAlign		=	tempArray[4];
				//文本编号
				actionItem.TalkInfo			=	StaticIni.getSwfLangStr(tempArray[5]);
				//NPC面向
				actionItem.ImageAlign		=	tempArray[6];
				//NPC初始位置
				tempPointArray				=	(tempArray[7] as String).split("_")
				actionItem.NpcStartPoint	=	new Point(tempPointArray[0], tempPointArray[1]);
				actionItem.IconType			=	tempArray[8];
				//NPC结束位置
				tempPointArray				=	(tempArray[8] as String).split("_")
				actionItem.NpcEndPoint		=	new Point(tempPointArray[0], tempPointArray[1]);
				if (actionItem.type == 1) 
				{
					//添加场景对象
					addNpc(actionItem.NpcConfigID, actionItem.NpcStartPoint,actionItem.ImageAlign,actionItem);
				}
			}
			//加入动作数组
			talkItemArray.push(actionItem);
		}

		/**
		 * 添加对话NPC
		 */
		private function addNpc(configID:String,startPoint:Point,imageAlign:int,moveObj:StoryVo= null):void
		{
			var tempMc:TalkActionPlay
			if (talkNpcObj[configID] == null)
			{
				tempMc	=	new TalkActionPlay();
				playSkinList.push(tempMc);
				playSkinList.push(configID);
//				tempMc.setSkin(configID);
				tempMc.x				=	startPoint.x;
				tempMc.y				=	startPoint.y;
				talkNpcObj[configID]	=	tempMc;			
				playSpace.addChild(tempMc);
				tempMc.ImageAlign		=	imageAlign;
				tempMc.setName(moveObj.Name)
					
				var titleName:String = StaticIni.getSwfLangStr("TitleName_"+configID);
				if(titleName == "TitleName_" + configID)
				{
					titleName = "";
				}
					
				tempMc.setTitleName(titleName);
				if(tempMc.skin != "")
				{
					_sourUrlArray.push(tempMc.skin);
				}
			}
			if (moveObj != null) 
			{
				moveObj.actionNPC		=	talkNpcObj[configID];
			}
		}

		/**
		 * 添加显示背景
		 * @param	val
		 */
		private function addSceneBG(configID:int):void
		{
			
			_bitMap = new Bitmap( new BitmapData( 1280, 768, false, 0 ));
			
			var rect : Rectangle = _bitMap.bitmapData.rect;
			var norSceneView : SceneView = SceneManager.getInstance().norSceneView;
			
			var sceneX : int = norSceneView.x > -600 ? -600 : norSceneView.x;
			rect.x = Math.min( - sceneX + SceneChangeManager.getGameMinWidhtOffsize(), 2500 - 1280 );
			_bitMap.bitmapData.copyPixels( norSceneView.sceneBitMap.bitmapData, rect, new Point( 0, 0) );
			
			//特殊处理
			bSceneBack.addChild( _bitMap );
			
			rect = null;
			
			
//			var start : int = 6;
//			var url:String	=	"";
//			
//			var isNewScene : int = StaticIni.getIniObj( "Scene_IsNewSceneLoading" )[ configID ];
////			for( var j : int = start; j <= start + 12; j++ )
////			{
////				SwfLoader.StartLoad( "res/scenes/" + "bscene_" + configID + "_" + j + ".swf", null,onComplete0,[j] );
////				_sourUrlArray.push("res/scenes/" + "bscene_" + configID + "_" + j + ".swf");
////			}
//			function onComplete0( swf : MovieClip, pList : Array ):void
//			{
//				swf.x = ( pList[0] -start) * 100;
//				bSceneBack.addChild( swf );
//			}
//			for( var i : int = start; i <= start + 12; i++ )
//			{
//				if( 1 == isNewScene )
//				{
//					SwfLoader.StartLoad( "res/scenes/" + "mscene_" + configID + "_" + i + ".swf", null,onComplete,[i, isNewScene] );
//				}else
//				{
//					SwfLoader.StartLoad( "res/scenes/" + "mscene_" + configID + "_" + i + ".swf", null,onComplete,[i, isNewScene] );
//				}
//			}
//			function onComplete( swf : MovieClip, pList : Array ):void
//			{
//				swf.x = ( pList[0] -start) * 100;
//				sceneBlack.addChild( swf );
//			}
//			if( isNewScene == 1 )
//			{
//				//加载前景
//				SwfLoader.StartLoad( "res/scenes/" + "fscene_" + configID + ".swf", null,onComplete1 );
//				function onComplete1( swf : MovieClip, pList : Array ):void
//				{
//					if( null == swf )
//					{
//						return;
//					}
//					frameBlack.addChild( swf );
//				}
//			}
		}
		/**
		 * 清空所有显示对像
		 */
		private function clearAll():void
		{
			while (sceneBlack.numChildren > 0) 
			{
				sceneBlack.removeChildAt(0)
			}
			while (playSpace.numChildren > 0) 
			{
				playSpace.removeChildAt(0)
			}
			while(frameBlack.numChildren > 0)
			{
				frameBlack.removeChildAt(0);
			}
			while(bSceneBack.numChildren > 0)
			{
				bSceneBack.removeChildAt(0);
			}
			
		}
		/**
		 * 获取NCP名称
		 */
		private function getNpcName(val:String):String
		{
			var npcName: String	=	"";
			if (val == "-1") 
			{
				npcName	=	_model.scene.Role.getPlayerName();
			}
			else
			{
				npcName	=	StaticIni.getSwfLangStr(val);
			}
			return npcName;
		}
		override public function show(space:DisplayObjectContainer = null, onshow:Function = null, ...argc):void 
		{
			if (space == null) 
			{
				space = StageInfo.storyMoveSpace;
			}
			if (space.numChildren > 0) 
			{
				this.removeChildAt(0);
			}
			this.x	=	0;
			this.y	=	0;
			space.addChild(this);
			
			changeLocation();
		}
		//不用的关闭界面方法
		override public function hide():void 
		{
			return;
		}
		/**
		 * 新的过场关闭界面
		 * @param talkInfo
		 * 
		 */		
		private function closeStoryMovie(val:StoryVo):void
		{
			talkMask.visible	=	false;
			talkSpace.mask		=	null;
			_endBlackInfoUI.addEventListener(StoryEvent.SHOW_SCENE,endShowSceneHandle);
			_endBlackInfoUI.addEventListener(StoryEvent.TALK_OVER,endTalkOverHandle);
			while(talkSpace.numChildren > 0)
			{
				talkSpace.removeChildAt(0);
			}
			talkSpace.addChild(_endBlackInfoUI);
			_endBlackInfoUI.showInfo(val);

		}
		/**
		 * 显示场景内容
		 * @param e
		 * 
		 */		
		private function endShowSceneHandle(e:StoryEvent):void
		{
			frameMask.visible	=	false;
			playMask.visible	=	false;
			sceneMask.visible	=	false
			sceneAll.mask		=	null
			playSpace.mask		=	null;
			frameBlack.mask		=	null;
			
			frameBlack.visible	=	false
			sceneAll.visible	=	false;
			playSpace.visible	=	false;
			maskSpce.visible	=	false;
			//storyFunBack.alpha	=	1;
			
			if( GameData.SceneType == GameDefine.SceneType_CS )
			{//如果是副本
				var npcs : Array = SceneManager.getInstance().norSceneView.scenePlayerLogic.getNpcs();
				if( npcs.length == 1 )
				{//只有一个npc,直接进入战斗
					if((npcs[0] as NpcModel).visible)
					{
						MainUIManager.getInstance().hideAll();
						SystemSender.getInstance().SelectObjInScene( npcs[0].playerObj.ObjID, 1 );
					}
				}
				else
				{//变成点击副本草连接
					MainUIManager.getInstance().showAll();
					GameData.Role.startMove( [ new Point( 2400, 650 ) ]);
				}
			}else
			{
				MainUIManager.getInstance().showAll();
			}
		}
		/**
		 * 关闭剧情播放界面
		 * @param e
		 * 
		 */		
		private function endTalkOverHandle(e:StoryEvent):void
		{
			
			_endBlackInfoUI.removeEventListener(StoryEvent.SHOW_SCENE,endShowSceneHandle);
			_endBlackInfoUI.removeEventListener(StoryEvent.TALK_OVER,endTalkOverHandle);
			removeAll();
			
			InterceptMsgLogic.getInstance().sendAll();
			var newStoryID:String = StoryLogic.getInstance().comStoryID
//			if(newStoryID == "Story_500001")
//			{
//				SceneManager.getInstance().onSwitchScene(_sceneEvent);
//			}
		}
		/**
		 * 直接关了自己，啥也不做 
		 * 加了个有活做完了的就去寻路去了！
		 */		
		private function removeAll():void
		{
			if (this.parent)
			{
				this.parent.removeChild(this);
			}
			
			IsStory =false;
			
			if( MainUIManager.getInstance().autoFoundWay )
			{
				MainUIManager.getInstance().autoFoundWay = true;
			}
			
			if( GameData.SceneType == GameDefine.SceneType_CS )
			{//如果是副本
				var npcs : Array = SceneManager.getInstance().norSceneView.scenePlayerLogic.getNpcs();
				if( npcs.length == 1 && (npcs[0] as NpcModel).visible)
				{//只有一个npc,直接进入战斗
//					MainUIManager.getInstance().hideAll();
					
				}else
				{//变成点击副本草连接
					
					MainUIManager.getInstance().showAll();
					SceneManager.getInstance().showSceneView();
				}
			}else
			{
				MainUIManager.getInstance().showAll();
				SceneManager.getInstance().showSceneView();
			}
			
			TalkInformationUI.getInstance().first = true;
			//TaskTrackingUI.getInstance().autoLink();
		}
		private function getRoleModle():String
		{
			var roleModel:String	=	"";
			roleModel =	String(_model.scene.Role.GetPropertiesEx("Model")) + String(_model.scene.Role.GetPropertiesEx("ClotheModel") == 0?1:_model.scene.Role.GetPropertiesEx("ClotheModel"))
			return roleModel;
		}
	}

}